<template>
  <div class="app-container">
    <!-- 页面头部 -->
    <header class="header">
      <h1>我的Vue应用</h1>
    </header>

    <!-- 导航栏 -->
    <nav class="nav-bar">
      <RouterLink
          v-for="route in routes"
          :key="route.path"
          :to="route.path"
          class="nav-link"
          active-class="active"
      >
        {{ route.name }}
      </RouterLink>
    </nav>

    <!-- 内容展示区 -->
    <main class="content">
      <RouterView></RouterView>
    </main>
  </div>
</template>

<script setup lang="ts">
import {RouterLink, RouterView} from "vue-router";

const routes = [
  {path: '/news', name: '新闻'},
  {path: '/pictures', name: '图片'},
  {path: '/knowledge', name: '知识'},

];
</script>

<style scoped>
.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: #2c3e50;
  color: white;
  padding: 1rem;
  text-align: center;
}

.nav-bar {
  display: flex;
  background: #f8f9fa;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-link {
  padding: 0.5rem 1rem;
  margin: 0 1rem;
  text-decoration: none;
  color: #2c3e50;
  border-radius: 4px;
  transition: all 0.3s;
}

.nav-link:hover {
  background: #e9ecef;
}

.active {
  background: #3498db;
  color: white;
}

.content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto; /* 内容过多时出现滚动条 */
}
</style>
